package com.itheima.thread.communication.demo01;

//生产者线程的任务类
public class ProducerThread implements Runnable {

    private Box box;
    public ProducerThread(Box box) {
        this.box = box;
    }

    //定义一个标志位的变量
    private int count = 0;

    @Override
    public void run() {

        while (true) {

            if(count % 2 == 0) {

                box.setMilkType("牛奶");
                box.setAmount("5L");

            }else {

                box.setMilkType("羊奶");
                box.setAmount("10L");

            }

            //对标志位的变量进行++操作
            count++;

        }

    }
}
